<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信号</title>
    <script type=text/javascript th:src="@{'/js/jedate/jquery-1.7.2.js'}"></script>
</head>
<body>

<table>
    <tr>
        <td>微信号</td>
        <td th:text="${obj.wxh}"></td>
    </tr>
    <tr>
        <td>备注</td>
        <td th:text="${obj.remark}"></td>
    </tr>
    <tr>
        <td>操作</td>
        <td><input type="button" value="启动" id="qidong"/></td>
    </tr>
    <tr>
        <td>二维码</td>
        <td><img id="img" style="width: 200px;height: 200px;" th:src="@{'/temp/'+${obj.wxh}+'/qr.png'}"/></td>
    </tr>
    <tr>
        <td>数据报表</td>
        <td><a th:href="@{report(wxh=${obj.wxh})}" target="_blank">查看</a></td>
    </tr>
</table>

</body>
</html>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        $("#qidong").click(function () {
            if (confirm("你确定要启动该机器人吗?")) {
                $.post("start", {wxh: [[${obj.wxh}]]}, function () {
                    var imgUrl = '/temp/';
                    imgUrl = imgUrl + [[${obj.wxh}]];
                    imgUrl = imgUrl + '/qr.png';
                    alert("已启动,二维码出现后请进行扫码登录.")
                    $("#img").attr("src", imgUrl + "?d=" + new Date());
                    setInterval(function () {
                        $("#img").attr("src", imgUrl + "?d=" + new Date());
                    }, 5000);
                });
            }
        });
    });
</script>